package com.aaa.controller;

import com.aaa.service.T_CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: TT
 * @Date: 2019/3/8 10:45
 * @Version 1.0
 */
@Controller
@RequestMapping("Comment")
public class T_CommentController {
    @Autowired
    private T_CommentService service;

    @RequestMapping("go")
    public  String  go(){
        return  "appraisalitems/appraisalitems";
    }
    @RequestMapping("list")
    @ResponseBody
    public Map list(@RequestBody Map map){

        List<Map>  data=service.getAll(map);

        Integer  integer=service.getCount(map);
        Map map1=new HashMap();
        map1.put("data",data);
        map1.put("total",integer);
        if (data.size()==0){
            map1.put("size",0);
        }else {
            map1.put("size",1);
        }
        return  map1;
    }
    @RequestMapping("insert")
    @ResponseBody
    public Integer insert(@RequestBody Map map){
         Integer row=service.insert(map);
         return  row;
    }
    @RequestMapping("update")
    @ResponseBody
    public Integer update(@RequestBody Map map){
        Integer row=service.update(map);
        return  row;
    }
    @RequestMapping("del/{id}")
    @ResponseBody
    public  Integer del(@PathVariable Map map){
        Integer row=service.del(map);
        return row;
    }
    @RequestMapping("open/{id}")
    @ResponseBody
    public Integer open(@PathVariable Integer id){
        return  service.open(id);
    }
}
